package pack;
import java.net.SocketException;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

import pack.TimeServer.Client;





/*@Author Shailendra Kumar M*/


public class TimeClient {
   private void start() throws SocketException{
      TTransport transport;
      try {
    	  System.out.println("in method" );
         transport = new TSocket("localhost", 7911);
         TProtocol protocol = new TBinaryProtocol(transport);
         Client client = new TimeServer.Client(protocol);
         System.out.println("open transport" );
         transport.open();
         System.out.println("opened transport" );
         long time = client.time();
         System.out.println("client called"+time );
         System.out.println("Time from server:" + time);
         transport.close();
      } catch (TTransportException e) {
         e.printStackTrace();
      } catch (TException e) {
         e.printStackTrace();
      }
   }
//This is client program hhjkh
   // nihar has written this statement 
   public static void main(String[] args) {
	   System.out.println("Main executed" );
      TimeClient c = new TimeClient();
      try {
    	  System.out.println("calling start" );
		c.start();
	} catch (SocketException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
   }
   //never give up
}// end of the program
